#ifndef APPENGINE_H
#define APPENGINE_H

#include <QCoreApplication>
#include <QDebug>
#include <QMutex>
#include <QObject>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QSettings>

#include "modbustcp_class.h"
#include "historymodel.h"

#include "processdatamanager.h"
#include "parametermodel.h"
#include "parameteritem.h"

#include "initdata.h"
#include "scannercontrol.h"
#include "printercontrol.h"

class AppEngine : public QQmlApplicationEngine
{
    Q_OBJECT

public:
    static AppEngine *getInstance();

    static void destroyInstance();

    void registerType();

    // 提供参数管理类的访问接口
    ProcessDataManager *processDataManager() const { return m_ProcessDataManager; }

private:
    AppEngine(QObject *parent = nullptr);
    ~AppEngine();
    AppEngine(const AppEngine &) = delete;
    AppEngine &operator=(const AppEngine) = delete;

    static AppEngine *m_instance;
    static QMutex m_mutex;

    ModbusTCP_Class *m_ModbusTCP = nullptr;
    HistoryModel* m_History = nullptr;

    // 参数管理相关实例
    ProcessDataManager *m_ProcessDataManager = nullptr;
    ParameterModel* m_ProcessModel = nullptr;
    ParameterItem* m_ProcessItem = nullptr;

    // 配置文件操作对象
    InitData* m_Init = nullptr;
    ScannerControl* m_Scanner = nullptr;
    PrinterControl* m_Printer = nullptr;

signals:
};

#endif // APPENGINE_H
